"use strict";
const { Model } = require("sequelize");
module.exports = (sequelize, DataTypes) => {
  class Gg_user extends Model {
    /**
     * Helper method for defining associations.
     * This method is not a part of Sequelize lifecycle.
     * The `models/index` file will call this method automatically.
     */
    static associate(models) {
      // define association here
    }
  }
  Gg_user.init(
    {
      user_name: {
        type: DataTypes.STRING(50),
        allowNull: false,
        validate: {
          notNull: {
            msg: "用户名 必须存在!",
          },
          notEmpty: {
            msg: "用户名 不能为空!",
          },
          len: {
            args: [2, 50],
            msg: "用户名 需要在 2~50 个字符之间",
          },
        },
      },
      user_password: {
        type: DataTypes.STRING(50),
        allowNull: false,
        validate: {
          notNull: {
            msg: "密码 必须存在!",
          },
          notEmpty: {
            msg: "密码 不能为空!",
          },
          len: {
            args: [5, 55],
            msg: "密码 需要在 5~50 个字符之间",
          },
        },
      },
      user_type: {
        type: DataTypes.STRING(20),
        // 设置默认值
        defaultValue: "common",
      },
      user_onlinestatus: {
        type: DataTypes.INTEGER,
        defaultValue: 0,
      },
      user_other: {
        type: DataTypes.INTEGER,
        defaultValue: 1,
      },
    },
    {
      sequelize,
      modelName: "Gg_user",
    }
  );
  return Gg_user;
};
